package cn.wolfcode.p2p.business.domain;

import cn.wolfcode.p2p.base.domain.AuditBaseDomain;
import cn.wolfcode.p2p.util.Constant;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 线下充值
 */
@Setter
@Getter
public class RechargeOffline extends AuditBaseDomain {
    /**
     * 交易号
     */
    private String tradeCode;
    /**
     * 交易时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date tradeTime;

    private BigDecimal amount = Constant.ZERO;

    private String note;

    private PlatformBankInfo bankInfo;


    /**
     * json
     */
    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("username",getApplier().getUsername());
        map.put("tradeCode",tradeCode);
        map.put("amount",amount);
        map.put("tradeTime", DateFormat.getDateInstance().format(tradeTime));
        return JSON.toJSONString(map);
    }

}